import requests

from com.yh.oa.utils.utils import oahost


class Person():
    def queryPersonList(self,token,pageNum=1,pageSize=10,roleName=""):
        params = {
        "pageNum":pageNum,
        "pageSize":pageSize,
        "roleName":roleName


        }

        resp = requests.get(oahost+"/system/role/list",params=params,headers=token)
        return resp

    def addPerson(self,roleName,roleKey,token,status="0"):
        list = {
    "roleName": roleName,
    "roleKey": roleKey,
    "roleSort": 0,
    "status": status
}

        resp = requests.post(oahost+"/system/role",json=list,headers=token)
        return resp

    def updatePerson(self,roleName,roleKey,token):
        list = {
            "roleName": roleName,
            "roleKey": roleKey,
            "roleSort": 0,
            "status": "0",
            "menuIds": [],
            "deptIds": []
        }
        resp = requests.put(oahost + "/system/role", json=list, headers=token)
        return resp

    def exportExcel(self,pageNum,pageSize,token):
        params = {
            "pageNum": pageNum,
            "pageSize": pageSize
        }
        resp = requests.get(oahost+"/system/role/export",params=params,headers=token)
        return resp

    def personId(self,roleId,token):
        params = {
            "roleId": roleId
        }
        resp = requests.get(oahost+"/system/role/{}".format(params),headers=token)
        return resp
    def personStatus(self,roleName,roleKey,token):
        list = {
            "roleName": roleName,
            "roleKey": roleKey,
            "roleSort": 0,
            "status": "0",
            "menuIds": [],
            "deptIds": []
        }

        resp = requests.put(oahost+"/system/role/changeStatus",json=list,headers=token)
        return resp

    def personSelect(self,token):
        resp = requests.get(oahost+"/system/role/optionselect",headers=token)
        return resp